#include<bits/stdc++.h>
using namespace std;
string st;
int n,q,s[1050000],l[1050000],r[1050000],pre[1050000],ans;
vector<int> vec[1050000];
int stktop,stk[1050000];
namespace seg {
    //cur=i: val[j]=max{pre[j],pre[j+1],...,pre[i]}-pre[j]
    //val[i]=0
    //stk[stktop]=x, stk[stktop-1]=y: val[k]=pre[x]-pre[k](stk[stktop]-stk[stktop-1]) (y<k<=x)
    //if pre[i]>=pre[x]: pre[k]+=pre[i]-pre[x] (y<k<=x)
    int sgt[4050000][2];//max,tag
    void pushdown(int p,int s,int t) {
        if (s==t) {
            sgt[p][1]=0;
            return;
        }
        sgt[p*2][0]+=sgt[p][1];
        sgt[p*2][1]+=sgt[p][1];
        sgt[p*2+1][0]+=sgt[p][1];
        sgt[p*2+1][1]+=sgt[p][1];
        sgt[p][1]=0;
    }
    void update(int p,int s,int t,int l,int r,int x) {
        pushdown(p,s,t);
        if ((l<=s)&&(t<=r)) {
            sgt[p][0]+=x;
            sgt[p][1]+=x;
            return;
        }
        int mid=(s+t)/2;
        if (l<=mid) update(p*2,s,mid,l,r,x);
        if (r>mid) update(p*2+1,mid+1,t,l,r,x);
        sgt[p][0]=max(sgt[p*2][0],sgt[p*2+1][0]);
    }
    int getmax(int p,int s,int t,int l,int r) {
        pushdown(p,s,t);
        if ((l<=s)&&(t<=r)) {
            return sgt[p][0];
        }
        int mid=(s+t)/2;
        if (r<=mid) return getmax(p*2,s,mid,l,r);
        if (l>mid) return getmax(p*2+1,mid+1,t,l,r);
        return max(getmax(p*2,s,mid,l,r),getmax(p*2+1,mid+1,t,l,r));
    }
}
int main() {
    freopen("good.in","r",stdin);
    freopen("good.out","w",stdout);
    cin>>n>>q>>st;
    for (int i=1;i<=n;i++) {
        if (st[i-1]=='0') s[i]=0;
        else s[i]=1;
    }
    for (int i=1;i<=q;i++) {
        scanf("%d%d",&l[i],&r[i]);
        vec[r[i]].push_back(l[i]);
    }
    for (int i=1;i<=n;i++) {
        if (s[i]) pre[i]=pre[i-1]+1;
        else pre[i]=pre[i-1]-1;
    }
    stktop=1;
    for (int i=1;i<=n;i++) {
        while (stktop&&(pre[stk[stktop]]<=pre[i])) {
            seg::update(1,0,n,stk[stktop-1]+1,stk[stktop],pre[i]-pre[stk[stktop]]);
            stktop--;
        }
        stk[++stktop]=i;
        for (auto x:vec[i]) {
            int tmp=seg::getmax(1,0,n,x-1,i);
            if (tmp==0) tmp=1;
            ans^=tmp-pre[i]+pre[x-1];
        }
    }
    printf("%d\n",ans);
    return 0;
}
